local Plugin = SS.Plugins:New("Exploits")

// Tables

Plugin.Prevent = {}

// Balloons

CreateConVar("exploits_balloons", 50000, FCVAR_NOTIFY)

Plugin.Prevent["balloon"] = function(Player)
	local Limit = GetConVarNumber("exploits_balloons")
	
	if (Player:GetInfoNum("balloon_force", 0) > Limit) then
		Player:ConCommand("balloon_force "..Limit.."\n")
		
		SS.PlayerMessage(Player, "This balloon force could crash the server, it has been lowered!", 1)
		
		return false
	elseif (Player:GetInfoNum("balloon_force", 0) < -Limit) then
		Player:ConCommand("balloon_force -"..Limit.."\n")
		
		SS.PlayerMessage(Player, "This balloon force could crash the server, it has been raised!", 1)
		
		return false
	end
	
	return true
end

// Motors

CreateConVar("exploits_torque", 25000, FCVAR_NOTIFY)

Plugin.Prevent["motor"] = function(Player)
	local Limit = GetConVarNumber("exploits_torque")
	
	if (Player:GetInfoNum("motor_torque", 0) > Limit) then
		Player:ConCommand("motor_torque "..Limit.."\n")
		
		SS.PlayerMessage(Player, "This torque could crash the server, it has been lowered!", 1)
		
		return false
	elseif (Player:GetInfoNum("motor_torque", 0) < -Limit) then
		Player:ConCommand("motor_torque -"..Limit.."\n")
		
		SS.PlayerMessage(Player, "This torque could crash the server, it has been raised!", 1)
		
		return false
	end
	
	return true
end

// Wheels

Plugin.Prevent["wheel"] = function(Player)
	local Limit = GetConVarNumber("exploits_torque")
	
	if (Player:GetInfoNum("wheel_torque", 0) > Limit) then
		Player:ConCommand("wheel_torque "..Limit.."\n")
		
		SS.PlayerMessage(Player, "This torque could crash the server, it has been lowered!", 1)
		
		return false
	elseif (Player:GetInfoNum("wheel_torque", 0) < -Limit) then
		Player:ConCommand("wheel_torque -"..Limit.."\n")
		
		SS.PlayerMessage(Player, "This torque could crash the server, it has been raised!", 1)
		
		return false
	end
	
	return true
end

// Thrusters

CreateConVar("exploits_thrusters", 500000, FCVAR_NOTIFY)

Plugin.Prevent["thruster"] = function(Player)
	local Limit = GetConVarNumber("exploits_thrusters")
	
	if (Player:GetInfoNum("thruster_force", 0) > Limit) then
		Player:ConCommand("thruster_force "..Limit.."\n")
		
		SS.PlayerMessage(Player, "This thruster force could crash the server, it has been lowered!", 1)
		
		return false
	elseif (Player:GetInfoNum("thruster_force", 0) < -Limit) then
		Player:ConCommand("thruster_force -"..Limit.."\n")
		
		SS.PlayerMessage(Player, "This thruster force could crash the server, it has been raised!", 1)
		
		return false
	end
	
	return true
end

// Weight

CreateConVar("exploits_weight", 50000, FCVAR_NOTIFY)

Plugin.Prevent["weight"] = function(Player)
	local Limit = GetConVarNumber("exploits_weight")
	
	if (Player:GetInfoNum("weight_set", 0) > Limit) then
		Player:ConCommand("weight_set "..Limit.."\n")
		
		SS.PlayerMessage(Player, "This weight could crash the server, it has been lowered!", 1)
		
		return false
	elseif (Player:GetInfoNum("weight_set", 0) < 0) then
		Player:ConCommand("weight_set 0\n")
		
		SS.PlayerMessage(Player, "This weight could crash the server, it has been raised!", 1)
		
		return false
	end
	
	return true
end

// Stacker

CreateConVar("exploits_ol_stacker", 50, FCVAR_NOTIFY)

Plugin.Prevent["ol_stacker"] = function(Player)
	local Limit = GetConVarNumber("exploits_ol_stacker")
	
	if (Player:GetInfoNum("ol_stacker_count", 0) > Limit) then
		Player:ConCommand("ol_stacker_count "..Limit.."\n")
		
		SS.PlayerMessage(Player, "This amount of entities could crash the server, it has been lowered!", 1)
		
		return false
	end
	
	return true
end
 

// Can use the toolgun

function Plugin.CanTool(Player, Trace, Tool)
	if (Plugin.Prevent[Tool]) then
		local Return = Plugin.Prevent[Tool](Player)
		
		if not (Return) then
			return false
		end
	end
end

hook.Add("CanTool", "Exploits.CanTool", Plugin.CanTool)

Plugin:Create()